var fs = require('fs');



module.exports = class QHtmlView {

    async render(filename, locals) {

        const config = Object.assign({}, this.config, { filename });

        return new Promise((resolve, reject) => {

            fs.readFile(filename, 'utf-8', (err, data) => {

                if (err) {
                    reject(err)
                } else {
                    data = data.replace(/\$\{([^}]+)\}/g, function ($1, $2) {
                        let key = $2.trim();
                        let value = locals[key];
                        if (value != undefined) return value;
                        return $1;

                    })
                    
                    resolve(data)
                }
            })

        })
    }

    renderString(tpl, locals) {

    }

}